package com.asd.map.controller;

import cn.hutool.core.util.URLUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.asd.common.Result;
import com.asd.config.IdGenerator;
import com.asd.map.entity.Information;
import com.asd.map.entity.Map_apply;
import com.asd.map.entity.Point_position;
import com.asd.map.mapper.MapApplyMappper;
import com.asd.map.service.ApplyService;
import com.asd.map.service.IInformationService;
import com.asd.map.service.ILine_surfaceService;
import com.asd.map.service.IPoint_positionService;
import com.asd.map.entity.Demo;
import com.asd.system.entity.ExcelFilesModel;
import com.asd.system.entity.User;
import com.asd.system.service.IUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.*;

/**
 * 数据源控制器
 *
 * @author
 * @createtime 2021-09-02 8:49
 * @description
 */

@Api(tags = "数据源Api")
@RestController
@RequestMapping("/api/information")
public class InformationController {

    @Autowired
    private IInformationService iInformationService;

    @Autowired
    private IPoint_positionService point_positionService;

    @Autowired
    private ILine_surfaceService line_surfaceService;

    @Autowired
    private ApplyService applyService;

    @Autowired
    private MapApplyMappper mapApplyMappper;

    @Autowired
    private IUserService userService;

    @Autowired
    private IdGenerator idGenerator;


    /**
     * 分页列表查询
     *
     * @param
     * @param pageNo
     * @param pageSize
     * @return
     */
    @ApiOperation(value = "数据源-分页列表查询", notes = "数据源-分页列表查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNo", value = "当前页"),
            @ApiImplicitParam(name = "pageSize", value = "分页大小")
    })
    @GetMapping(value = "/list")
    public Result<?> queryPageList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                   @RequestParam(name = "pageSize", defaultValue = "5") Integer pageSize) {
//        Page<Information> page = new Page<Information>(pageNo, pageSize);
//
//
//        List<Information> list = iInformationService.selectInformationPage(page);
//
//        Page<Information> pageList = page.setRecords(list);


        List<Information> mipList = iInformationService.list(new QueryWrapper<Information>().orderByDesc("create_time"));
        //将mipList分页并返回
        Page page = new Page();
        int size = mipList.size();
        if (pageSize > size) {
            pageSize = size;
        }
        //求出最大页数，防止pageNo越界
        int maxPage = size % pageSize == 0 ? size / pageSize : size / pageSize + 1;
        if (pageNo > maxPage) {
            pageNo = maxPage;
        }
        //当前页第一条数据下标
        int curIds = pageNo > 1 ? (pageNo - 1) * pageSize : 0;

        List pageList = new ArrayList<>();

        //将当前页的数据放进pageList
        for (int i = 0; i < pageSize && curIds + i < size; i++) {
            pageList.add(mipList.get(curIds + i));
        }
        page.setCurrent(pageNo).setSize(pageSize).setTotal(mipList.size()).setRecords(pageList);


        return Result.ok(page);
    }


    /**
     * 根据用户ID查询数据源数据数据
     *
     * @param userId
     * @param pageNo
     * @param pageSize
     * @return
     */
    @ApiOperation(value = "应用数据-根据用户ID查询数据源数据", notes = "应用数据-根据用户ID查询数据源数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id"),
            @ApiImplicitParam(name = "pageNo", value = "当前页"),
            @ApiImplicitParam(name = "pageSize", value = "分页大小")
    })
    @GetMapping("/queryInformationByUserId")
    public Result<Object> queryInformationByUserId(@RequestParam("userId") String userId,
                                                   @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                   @RequestParam(name = "pageSize", defaultValue = "5") Integer pageSize) {

        ArrayList<Information> mipList = new ArrayList<>();

        User user = userService.getById(userId);
        //获取本用户所有的应用id
        String dataInf = user.getDataInf();
        List<String> listInformationId = (List<String>) JSONArray.parse(dataInf);
        for (int i = 0; i < listInformationId.size(); i++) {
            Information information = iInformationService.getById(listInformationId.get(i));
            mipList.add(information);
        }

        //将mipList分页并返回
        Page page = new Page();
        int size = mipList.size();
        if (pageSize > size) {
            pageSize = size;
        }
        //求出最大页数，防止pageNo越界
        int maxPage = size % pageSize == 0 ? size / pageSize : size / pageSize + 1;
        if (pageNo > maxPage) {
            pageNo = maxPage;
        }
        //当前页第一条数据下标
        int curIds = pageNo > 1 ? (pageNo - 1) * pageSize : 0;

        List pageList = new ArrayList<>();

        //将当前页的数据放进pageList
        for (int i = 0; i < pageSize && curIds + i < size; i++) {
            pageList.add(mipList.get(curIds + i));
        }
        page.setCurrent(pageNo).setSize(pageSize).setTotal(mipList.size()).setRecords(pageList);
        return Result.ok(page);

    }


    /**
     * 添加 - 数据源
     *
     * @param name - 名称
     * @param type - 类型 0:点，1:线，2:面
     * @param data - 数据字段集合
     * @return
     */

    @ApiOperation(value = "数据源-添加", notes = "数据源-添加")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户ID", required = true),
            @ApiImplicitParam(name = "name", value = "名称", required = true),
            @ApiImplicitParam(name = "type", value = "类型 0:点，1:线，2:面"),
            @ApiImplicitParam(name = "data", value = "数据字段集合"),
            @ApiImplicitParam(name = "isImage", value = "是否添加图片 0：是，1：否")
    })
    @PostMapping(value = "/addInformation")
    public Result<?> add1(@RequestParam("userId") String userId, @RequestParam("name") String name, @RequestParam("type") String type,
                          @RequestParam("isImage") String isImage, @RequestParam("data") String data) {
        Information information = new Information();

        String id = idGenerator.nextId();
        information.setId(id);
        information.setData(data);
        information.setName(name);
        information.setType(type);
        information.setAddtype("0");
        information.setIsImage(isImage);

        iInformationService.save(information);


        User user = userService.getById(userId);

//        //获取本用户所有的应用id
        if (user.getDataInf() == null || user.getDataInf().equals("")) {
            List<String> list = new ArrayList<>();
            list.add(id);
            String str = JSON.toJSONString(list);
            user.setDataInf(str);
            userService.updateById(user);

        } else {
            List<String> informationId = (List<String>) JSONArray.parse(user.getDataInf());
            informationId.add(id);
            String str = JSON.toJSONString(informationId);
            user.setDataInf(str);
            userService.updateById(user);
        }


        return Result.ok("添加成功！");
    }

    @ApiOperation(value = "链接数据源-添加", notes = "链接数据源-添加")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户ID", required = true),
            @ApiImplicitParam(name = "name", value = "名称", required = true),
            @ApiImplicitParam(name = "type", value = "类型 0:点，1:线，2:面"),
            @ApiImplicitParam(name = "link", value = "链接"),
            @ApiImplicitParam(name = "data", value = "数据字段集合"),
            @ApiImplicitParam(name = "isImage", value = "是否添加图片 0：是，1：否")
    })
    @PostMapping(value = "/addInformationToLink")
    public Result<?> add1(@RequestParam("userId") String userId, @RequestParam("name") String name, @RequestParam("link") String link,@RequestParam("type") String type,
                          @RequestParam("isImage") String isImage, @RequestParam("data") String data) {
        Information information = new Information();

        String id = idGenerator.nextId();
        information.setId(id);
        information.setData(data);
        information.setName(name);
        information.setType(type);
        information.setAddtype("2");
        information.setIsImage(isImage);
        information.setLink(link);

        iInformationService.save(information);


        User user = userService.getById(userId);

//        //获取本用户所有的应用id
        if (user.getDataInf() == null || user.getDataInf().equals("")) {
            List<String> list = new ArrayList<>();
            list.add(id);
            String str = JSON.toJSONString(list);
            user.setDataInf(str);
            userService.updateById(user);

        } else {
            List<String> informationId = (List<String>) JSONArray.parse(user.getDataInf());
            informationId.add(id);
            String str = JSON.toJSONString(informationId);
            user.setDataInf(str);
            userService.updateById(user);
        }


        return Result.ok("添加成功！");
    }

    /**
     * 将数据源id存入应用中did对应数据的 data中
     *
     * @param id      - 数据源 id
     * @param applyId - 应用id
     * @return
     */

    @ApiOperation(value = "应用-数据源-添加", notes = "应用-数据源-添加")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "数据源 id", required = true),
            @ApiImplicitParam(name = "applyId", value = "应用id", required = true)
    })
    @PostMapping(value = "/addData")
    public Result<?> addData(@RequestParam("id") String id, @RequestParam("applyId") String applyId) {

        //获取一个随机的图层tid
        String tid = idGenerator.nextId();

        //根据应用id获取到应用信息
        Map_apply map_apply = applyService.getById(applyId);
        ArrayList<Map<String, Object>> list = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        //获取应用中的 data
        String data = map_apply.getData();
        /**
         * tid  图层id
         * ishow 图层显示 0：显示，1：不显示
         */
        // 当data为空时
        if (data == null || data.equals("")) {
            map.put("id", id);
            map.put(("tid"), tid);
            map.put("ishow", 1);
            list.add(map);
            String str = JSON.toJSONString(list);
            mapApplyMappper.updateById1(str, applyId);
        } else {   //data不为空时

            //将字符串转为list
            List<Map<String, Object>> listObjectFir = (List<Map<String, Object>>) JSONArray.parse(data);

            map.put("id", id);
            map.put(("tid"), tid);
            map.put("ishow", 1);
            listObjectFir.add(map);
            //将list转为字符串
            String str = JSON.toJSONString(listObjectFir);

            mapApplyMappper.updateById1(str, applyId);

        }
        return Result.ok("添加成功！");
    }


    @ApiOperation(value = "应用-数据源-批量添加", notes = "应用-数据源-批量添加")
    @PostMapping(value = "/batchAddData")
    public Result<?> batchAddData(@ApiParam(name = "ids", value = "数据源id使用,分割", required = true) @RequestParam("ids") String ids,
                                  @ApiParam(name = "applyId", value = "应用id", required = true) @RequestParam("applyId") String applyId) {


        //根据应用id获取到应用信息
        Map_apply map_apply = applyService.getById(applyId);
        ArrayList<Map<String, Object>> list = new ArrayList<>();

        //获取应用中的 data
        String data = map_apply.getData();


        Result<Collection<Information>> result = new Result<>();
        String[] userId = ids.split(",");
        List<String> idList = Arrays.asList(userId);


        /**
         * tid  图层id
         * ishow 图层显示 0：显示，1：不显示
         */
        // 当data为空时
        if (data == null || data.equals("")) {

            for (int i = 0; i < idList.size(); i++) {
                //获取一个随机的tid
                String tid = idGenerator.nextId();
                Map<String, Object> map = new HashMap<>();
                String id = idList.get(i);
                map.put("id", id);
                map.put(("tid"), tid);
                map.put("ishow", 1);
                list.add(map);
                String str = JSON.toJSONString(list);
                mapApplyMappper.updateById1(str, applyId);
            }

        } else {   //data不为空时

            //将字符串转为list
            List<Map<String, Object>> listObjectFir = (List<Map<String, Object>>) JSONArray.parse(data);

            for (int i = 0; i < idList.size(); i++) {
                //获取一个随机的tid
                String tid = idGenerator.nextId();
                Map<String, Object> map = new HashMap<>();
                String id = idList.get(i);
                map.put("id", id);
                map.put(("tid"), tid);
                map.put("ishow", 1);
                listObjectFir.add(map);
                //将list转为字符串
                String str = JSON.toJSONString(listObjectFir);

                mapApplyMappper.updateById1(str, applyId);
            }


        }
        return Result.ok("添加成功！");
    }


    /**
     * 修改图层状态
     *
     * @param tid
     * @param applyId 应用id
     * @param staId   ishow值
     * @return
     */
    @ApiOperation(value = "修改图层状态", notes = "修改图层状态")
    @PutMapping(value = "/updateStatus")
    public Result<?> updateStatus(@ApiParam(name = "tid", value = "图层id", required = true) @RequestParam("tid") String tid,
                                  @ApiParam(name = "applyId", value = "应用id", required = true) @RequestParam("applyId") String applyId,
                                  @ApiParam(name = "staId", value = "ishow值 0:显示 1：不显示", required = true) @RequestParam("staId") int staId) {

        Map_apply map_apply = applyService.getById(applyId);
        String data = map_apply.getData();
        List<Map<String, Object>> listObjectFir = (List<Map<String, Object>>) JSONArray.parse(data);
        for (int i = 0; i < listObjectFir.size(); i++) {
            String tid1 = (String) listObjectFir.get(i).get("tid");
            if (tid.equals(tid1)) {
                listObjectFir.get(i).put("ishow", staId);
                String str = JSON.toJSONString(listObjectFir);
                mapApplyMappper.updateById1(str, applyId);
            }

        }

        return Result.ok("修改成功！");
    }


    /**
     * 删除图层
     *
     * @param tid
     * @param applyId 应用id
     * @return
     */
    @ApiOperation(value = "删除图层", notes = "删除图层")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tid", value = "图层id", required = true),
            @ApiImplicitParam(name = "applyId", value = "应用id", required = true)
    })
    @DeleteMapping(value = "/deleteCov")
    public Result<?> deleteCov(@RequestParam("tid") String tid, @RequestParam("applyId") String applyId) {

        Map_apply map_apply = applyService.getById(applyId);
        String data = map_apply.getData();
        List<Map<String, Object>> listObjectFir = (List<Map<String, Object>>) JSONArray.parse(data);
        for (int i = 0; i < listObjectFir.size(); i++) {
            String tid1 = (String) listObjectFir.get(i).get("tid");
            if (tid.equals(tid1)) {
                listObjectFir.remove(i);
                String str = JSON.toJSONString(listObjectFir);

                mapApplyMappper.updateById1(str, applyId);
            }

        }

        return Result.ok("删除成功！");
    }


    /**
     * 编辑
     *
     * @param
     * @return
     */
    @ApiOperation(value = "数据源-编辑", notes = "数据源-编辑")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", required = true),
            @ApiImplicitParam(name = "name", value = "名称"),
            @ApiImplicitParam(name = "type", value = "类型 0:点，1:线，2:面"),
            @ApiImplicitParam(name = "data", value = "数据字段集合")
    })
    @PutMapping(value = "/update")
    public Result<?> edit(@RequestParam("id") String id, @RequestParam("name") String name,
                          @RequestParam("type") String type, @RequestParam("data") String data) {

        Information information = iInformationService.getById(id);

        if (!(name.equals(null) || name.equals(""))) {
            information.setName(name);
        }
        if (!(type.equals(null) || type.equals(""))) {
            information.setType(type);
        }
        if (!(data.equals(null) || data.equals(""))) {
            information.setData(data);
        }

        iInformationService.updateById(information);
        return Result.ok("编辑成功!");
    }


    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "数据源-通过id删除", notes = "数据源-通过id删除")
    @DeleteMapping(value = "/delete")
    public Result<?> delete(@RequestParam("id") String id, @RequestParam("userId") String userId) {

        //根据数据源id删除该数据源下的所有点位
        point_positionService.deleteByDid(id);
        //根据数据源id删除该数据源下的所有线面数据
        line_surfaceService.deleteByDid(id);

        User user = userService.getById(userId);
        if (StringUtils.isNotEmpty(user.getDataInf())) {
            List<String> informationId = (List<String>) JSONArray.parse(user.getDataInf());
            informationId.remove(id);
            String str = JSON.toJSONString(informationId);
            user.setDataInf(str);
            userService.updateById(user);
        }


        iInformationService.removeById(id);

        return Result.ok("删除成功!");
    }

    /**
     * 导入数据接口
     *
     * @return
     */
    @ApiOperation(value = "导入数据接口", notes = "导入数据接口")
    @PostMapping("/importExcel")
    public Result<?> importExcel(@RequestParam("userId") String userId, @RequestBody ExcelFilesModel excelFilesModel) throws JsonProcessingException {

        //新增数据源
        Information information = new Information();
        String id = idGenerator.nextId();
        information.setId(id);
        information.setIsImage(excelFilesModel.getIsImage());

        information.setName(excelFilesModel.getName());
        information.setType(excelFilesModel.getType());
        information.setAddtype("1");

        String str = excelFilesModel.getData();
        String data = str.replace(",经度,纬度", "");

        information.setData(data);


        iInformationService.save(information);


        //数据源绑定登录用户
        User user = userService.getById(userId);
//        //获取本用户所有的数据源id
        if (user.getDataInf() == null || user.getDataInf().equals("")) {
            List<String> list = new ArrayList<>();
            list.add(id);
            String str1 = JSON.toJSONString(list);
            user.setDataInf(str1);
            userService.updateById(user);

        } else {
            List<String> informationId = (List<String>) JSONArray.parse(user.getDataInf());
            informationId.add(id);
            String str1 = JSON.toJSONString(informationId);
            user.setDataInf(str1);
            userService.updateById(user);
        }


        //excel表中数据存入到数据库中点位表
        String fileList = excelFilesModel.getFileList();

        if (!(fileList == null && fileList.equals(""))) {


            //将字符串转为List
            ObjectMapper mapper = new ObjectMapper();
            List<Map> list = mapper.readValue(fileList, List.class);


//            System.out.println("list====" + list.toString());
//
//
//            System.out.println("list===" + list);

            for (int i = 0; i < list.size(); i++) {


                Map<String, Object> map = list.get(i);

//                String pointName = map.get("名称");

                ArrayList<Object> arrayList = new ArrayList<>();
                Point_position point_position = new Point_position();


                for (Map.Entry<String, Object> entry : map.entrySet()) {
                    Map<String, String> map1 = new HashMap<>();

                    if (entry.getKey().equals("名称")) {
                        map1.put("name", entry.getValue().toString());
                        map1.put("valueName", entry.getKey());

                        arrayList.add(map1);
                    } else if (!(entry.getKey().equals("经度") || entry.getKey().equals("纬度"))) {
                        map1.put("value", entry.getValue().toString());
                        map1.put("valueName", entry.getKey());
                        arrayList.add(map1);

                    }

                }
                String lng = map.get("经度").toString();
                String lat = map.get("纬度").toString();


                String data1 = net.sf.json.JSONArray.fromObject(arrayList).toString();
                point_position.setData(data1);

                point_position.setDid(id);
                point_position.setLng(lng);
                point_position.setLat(lat);
                point_positionService.save(point_position);

            }
        }

        return Result.ok("导入成功");
    }

    @ApiOperation(value = "excel模板", notes = "excel模板")
    @GetMapping("/exportExcelTemplate")
    public void downDeviceManagementTemplate(HttpServletRequest req, HttpServletResponse res) throws IOException {


        String fileName = "点位示例数据" + ".xlsx";

        InputStream inputStream = getClass().getClassLoader().getResourceAsStream("static/excel/table.xlsx");


        // 转为POI的Workbook输出流，这样下载后 打开不报错，直接输出  流 的话，打开excel可能提示错误
        @SuppressWarnings("resource")
        XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
        String userAgent = req.getHeader("User-Agent");
        // 针对IE或者以IE为内核的浏览器：
        if (userAgent.contains("MSIE") || userAgent.contains("Trident")) {
            fileName = URLUtil.encode(fileName, "UTF-8");
        } else {
            // 非IE浏览器的处理：
            fileName = new String(fileName.getBytes("UTF-8"), "ISO-8859-1");
        }
        res.setHeader("Content-disposition", "attachment; filename=" + fileName);
        res.setContentType("application/vnd.ms-excel; charset=utf-8");
        res.setCharacterEncoding("UTF-8");
        // 将流中内容写出去
        OutputStream outputStream = res.getOutputStream();
        workbook.write(outputStream);
        outputStream.flush();
        outputStream.close();
    }

    /**
     * @param informationIds
     * @return
     * @功能：根据id 批量查询
     */
    @ApiOperation(value = "数据源-批量查询", notes = "数据源-批量查询")
    @RequestMapping(value = "/queryByIds", method = RequestMethod.GET)
    public Result<Collection<Information>> queryByIds(@ApiParam(name = "informationIds", value = "数据源id使用,分割", required = true) @RequestParam("informationIds") String informationIds) {
        Result<Collection<Information>> result = new Result<>();
        String[] userId = informationIds.split(",");
        Collection<String> idList = Arrays.asList(userId);
        Collection<Information> information = iInformationService.listByIds(idList);
        result.setSuccess(true);
        result.setResult(information);
        return result;
    }

    public static void main(String[] args) {

//
//        String str1 = JSON.toJSONString(str);
//
//        String[] str2 = JSON.parseObject(str1, new TypeReference<String[]>() {});


        List<String> list1 = new ArrayList<String>();
        list1.add("1");
        list1.add("2");
        list1.add("3");

        list1.remove("1");
        String string = JSON.toJSONString(list1);

    }
    /**
     * @param
     * @return
     * @功能：根据id 修改数据源链接
     */
    @ApiOperation(value = "数据源-链接修改", notes = "数据源-链接修改")
    @RequestMapping(value = "/updateToIndorLink", method = RequestMethod.PUT)

    public Result<?> updateLink(@RequestParam("id") String id,@RequestParam("link") String link){
        Information information = new Information();
        information.setId(id);
        information.setLink(link);
        iInformationService.updateById(information);
        return Result.ok("修改成功");
    }
    /**
     * @param
     * @return
     * @功能：根据id 批量查询
     */
    @ApiOperation(value = "数据源-数据接口demo", notes = "数据源-数据接口demo")
    @RequestMapping(value = "/demo", method = RequestMethod.GET)
    public ArrayList demo() {
        ArrayList<Demo> objects = new ArrayList<>();
        String lng ="99.915159";
        String lat ="25.689474";
        for (int i = 0; i <3 ; i++) {
            Demo demo = new Demo();
            demo.setId(String.valueOf(i));
            demo.setLng(String.valueOf(99.815159+i));
            demo.setLat(String.valueOf(25.589474+i));
            demo.setName("子归"+i);
            List<List<String>> data = new ArrayList<>();
            List<String> data1 = new ArrayList<>();
            data1.add("name");
            data1.add("子归"+i);
            List<String> data2 = new ArrayList<>();
            data2.add("age");
            data2.add("23"+i);
            data.add(data1);
            data.add(data2);
            demo.setData(data);
            List<String> primary = new ArrayList<>();
            primary.add("http://dtxt.iansn.com/pictures/262c2ae040d34edd88df949f4cbe7739.png");
            demo.setPrimaryEchopathlist(primary);

            List<String> vice = new ArrayList<>();
            vice.add("http://dtxt.iansn.com/pictures/262c2ae040d34edd88df949f4cbe7739.png");
            vice.add("http://dtxt.iansn.com/pictures/262c2ae040d34edd88df949f4cbe7739.png");
            vice.add("http://dtxt.iansn.com/pictures/262c2ae040d34edd88df949f4cbe7739.png");
            vice.add("http://dtxt.iansn.com/pictures/262c2ae040d34edd88df949f4cbe7739.png");
            demo.setViceEchopathlist(vice);
            demo.setIsAdd(true);
            demo.setLink("http://www.baidu.com");
            demo.setButton("按钮");
            objects.add(demo);
        }
        return objects;
    }
    @ApiOperation(value = "数据源-数据接口demo2", notes = "数据源-数据接口demo2")
    @RequestMapping(value = "/demo2", method = RequestMethod.GET)
    public ArrayList demo2() {
        ArrayList<Demo> objects = new ArrayList<>();
//        String lng ="98.915159";
//        String lat ="23.689474";
        for (int i = 0; i <3 ; i++) {
            Demo demo = new Demo();
            demo.setId(String.valueOf(i+10));
            demo.setLng(String.valueOf(98.915159+i));
            demo.setLat(String.valueOf(24.689474+i));
            demo.setName("江北"+i);
            List<List<String>> data = new ArrayList<>();
            List<String> data1 = new ArrayList<>();
            data1.add("name");
            data1.add("江北"+i);
            List<String> data2 = new ArrayList<>();
            data2.add("age");
            data2.add("17"+i);
            data.add(data1);
            data.add(data2);
            demo.setData(data);
            List<String> primary = new ArrayList<>();
            //primary.add("http://dtxt.iansn.com/pictures/262c2ae040d34edd88df949f4cbe7739.png");
            demo.setPrimaryEchopathlist(primary);

            List<String> vice = new ArrayList<>();
//            vice.add("http://dtxt.iansn.com/pictures/262c2ae040d34edd88df949f4cbe7739.png");
//            vice.add("http://dtxt.iansn.com/pictures/262c2ae040d34edd88df949f4cbe7739.png");
//            vice.add("http://dtxt.iansn.com/pictures/262c2ae040d34edd88df949f4cbe7739.png");
//            vice.add("http://dtxt.iansn.com/pictures/262c2ae040d34edd88df949f4cbe7739.png");
            demo.setViceEchopathlist(vice);
            demo.setIsAdd(false);
            demo.setLink("");
            demo.setButton("");
            objects.add(demo);
        }
        return objects;
    }

}
